#!/usr/bin/python

import pandas as pd
import sys
import json
import os
from requests import get

sss_url = "http://swoogle.umbc.edu/SimService/GetSimilarity"

#s1 = "hello world"
#s2 = "hi world"

#This function comes from the UMBC Semantic Similarity service: http://swoogle.umbc.edu/SimService/phrase_similarity.html
#This semantic similarity is based on Refined Stanford WebBase corpus.
def semantic_similarity(s1, s2, type='relation', corpus='webbase'):
	try:
		response = get(sss_url, params={'operation':'api','phrase1':s1,'phrase2':s2,'type':type,'corpus':corpus})
		return float(response.text.strip())
	except:
#		print 'Error in getting similarity for %s: %s' % ((s1,s2), response)
		return 0.0

if __name__=="__main__":
#	s1 = "geography mountain elevation"
#	s2 = "geography mountain mountain range"
#	res = semantic_similarity(s1, s2)
#	print(str(semantic_similarity("highest", s2)))
#	print(str(semantic_similarity("highest mountain", s2)))
#	print(str(semantic_similarity("highest mountain on", s2)))
#	print(str(semantic_similarity("highest mountain on pacaraima", s2)))
#	print(str(semantic_similarity("highest mountain on pacaraima mountains", s2)))

	inputFile = sys.argv[1]

	f = open(inputFile, "r")
	line1 = f.readline()
	line2 = f.readline()
	print(str(semantic_similarity(line1, line2)))
	f.close()

